let arr1 = [1,2,3,4,5,6]
let arr2 = [1,2,3,4,5,6,7,8,9]
//如何来求两个数组的交集
let s1 = new Set(arr1)
let s2 = new Set(arr2)
let jjarr = []
arr1.forEach(value=>{
    if(s2.has(value))
        jjarr.push(value)
})
console.log([...new Set(jjarr)])


//如何求两个数组的差集
let cjarr = []
arr1.forEach(value=>{
    if(!s2.has(value))
        cjarr.push(value)
})
arr2.forEach(value=>{
    if(!s1.has(value))
        cjarr.push(value)
})
console.log([...new Set(cjarr)])